package com.ftg.learn.boot.mapper;

import com.ftg.learn.boot.pojo.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


import java.util.List;
@Mapper
@Repository
public interface DeptMapper {

    @Select("select * from dept where deptno=ifnull(#{arg2},deptno) or dname like ifnull(concat('%',#{arg3},'%'),dname) limit #{arg0},#{arg1}")//10
    List<Dept> showall(int begin,int end,String deptno,String dname);

    @Select("select count(*) from dept where deptno=ifnull(#{arg0},deptno) or dname like ifnull(concat('%',#{arg1},'%'),dname)")//11
    int getCount(String deptno,String dname);

    @Delete("delete from dept where deptno = #{deptno}")
    int deleteDeptno(int deptno);

    @Update("update dept set dname = #{dname},loc=#{loc} where deptno = #{deptno}")
    int update(Dept dept);

    @Insert("insert into dept (deptno,dname,loc) values(#{deptno},#{dname},#{loc})")
    int add(Dept dept);
}
